<?php
namespace app\api\controller;
use app\common\controller\Frontend;

use hg\apidoc\annotation as Apidoc;

#[Apidoc\Title("Apidoc基础示例")]
class ApidocTest extends Frontend
{
    protected array $noNeedLogin = ['index'];

    public function initialize(): void
    {
        parent::initialize();
    }

    #[
        Apidoc\Title("Apidoc基础的演示"),
        Apidoc\Tag("apidoc,基础,示例"),
        Apidoc\Method("GET"),
        Apidoc\Url("/api/ApidocTest/index"),
        Apidoc\Query(name:"name",type: "string",require: true,desc: "姓名",mock:"@name"),
        Apidoc\Query(name:"phone",type: "string",require: true,desc: "手机号",mock:"@phone"),
        Apidoc\Returned("id",type: "int",desc: "Id"),
    ]
    public function index(): void
    {
        $params = $this->request->get();
        $this->success('', [
            'title' => "第一个接口",
            'name' => $params['name'],
            'phone' => $params['phone'],
            'content' => "欢迎使用Apidoc",
        ]);
    }
}